﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;

namespace LabyCLI.Commands
{
	class cmd_rm
    {
        Terminal frm = Terminal.Instance;

        public void Main(List<string> args)
        {
            foreach (string arg in args)
            {
                if (File.Exists(arg))
				{
					File.Delete(arg);

                    if (!File.Exists(arg))
                    {
                        Terminal.WriteLine("The file: '" + arg + "' was succesfully deleted." + Environment.NewLine);
                    }
                }
				else if (Directory.Exists(arg))
				{
					Directory.Delete(arg);

					if (!Directory.Exists(arg))
					{
						Terminal.WriteLine("The directory: '" + arg + "' was succesfully deleted." + Environment.NewLine);
					}
				}
                else
				{
					Terminal.WriteLine("Invaild file or directory: '" + arg + "'." + Environment.NewLine, Properties.Settings.Default.Terminal_ErrorForeColor);
				}
            }
        }

        public void Main()
        {
            Terminal.WriteLine("Invaild amount of arguments." + Environment.NewLine, Properties.Settings.Default.Terminal_ErrorForeColor);
        }
    }
}
